package pro.softzhang.algo.lc400;

import java.util.Arrays;
import java.util.Comparator;

/**
 * 452. 用最少数量的箭引爆气球
 * https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons
 */
public class LC452_MinimumNumberOfArrowsToBurstBalloons {
    public static void main(String[] args) {

    }

    /**
     *
     */
    static
    class Solution {
        public int findMinArrowShots(int[][] points) {
            Arrays.sort(points, Comparator.comparingInt(p -> p[1]));
            int min = 0;
            long prev  = Long.MIN_VALUE;
            for (int[] p : points) {
                if (p[0] > prev) {
                    min++;
                    prev = p[1];
                }
            }
            return min;
        }
    }
}
